FROM golang:alpine as builder

WORKDIR /GoProject
COPY . .

RUN go env -w GO111MODULE=on
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go env -w CGO_ENABLED=0
RUN go env
RUN go mod tidy

#指定编译输出的名称为server
RUN go build main.go

FROM alpine:latest

WORKDIR /GoProject

# COPY 命令通过指定 --from=0 参数，把前一阶段构建的产物拷贝到了当前的镜像中
COPY --from=0 /GoProject ./

EXPOSE 8888

ENTRYPOINT ./server -c config.docker.yaml
